package lcr;

import java.util.Deque;
import java.util.LinkedList;

public class Test0041 {
}

class MovingAverage {

    Deque<Double> deque=new LinkedList<>();
    double sum=0;
    int size;

    /** Initialize your data structure here. */
    public MovingAverage(int size) {
        this.size=size;
    }

    public double next(int val) {
        if (deque.size()==size) sum-=deque.poll();
        sum+=val;
        deque.offer((double) val);
        return sum/deque.size();
    }
}